#include "private_implementations/JsonArray.h"
#include "private_implementations/JsonObject.h"
#include "interfaces/types/JsonTypeDefs.h"

namespace simframework
{
	namespace json
	{
		Array::Array(std::wostream& js):m_jsonStream(js), m_isFirstElement(true)
		{
			m_jsonStream << json_start_of_array;
		}

		Array::Array( const Array& other ):m_jsonStream(other.m_jsonStream), m_isFirstElement(other.m_isFirstElement)
		{

		}
		Array::~Array()
		{
			m_jsonStream << json_end_of_array;
		}

		Array Array::startArray()
		{	
			writeSeperator();
			return Array(m_jsonStream);
		}

		Object Array::startObject()
		{	
			writeSeperator();
			return Object(m_jsonStream);
		}

		void Array::writeSeperator()
		{
			if (m_isFirstElement)
			{
				m_isFirstElement = false;	
			}
			else
			{
				m_jsonStream << json_element_seperator;	
			}		
		}
	}
}